#!/bin/bash

echo "=== 构建并运行车辆召回数据分析应用 ==="
echo ""

# 检查Maven
if ! command -v mvn &> /dev/null; then
    echo "错误: 未找到Maven，请先安装Maven"
    exit 1
fi

echo "1. 清理并编译项目..."
mvn clean package -DskipTests

if [ $? -ne 0 ]; then
    echo "编译失败！"
    exit 1
fi

echo ""
echo "2. 检查生成的JAR文件..."
ls -la target/*.jar

echo ""
echo "3. 启动应用..."
echo "应用将在以下地址运行:"
echo "  - 完整版界面: http://$(hostname -I | awk '{print $1}'):8080"
echo "  - 简化版界面: http://$(hostname -I | awk '{print $1}'):8080/index2.html"
echo ""

# 运行应用
java -jar target/hadoop-1.0-SNAPSHOT.jar

echo ""
echo "应用已退出" 